<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- <h1>第一天</h1>
    <p>学习git</p> -->
    <div class="box" id="boxid" key="1">
        我是一个盒子
    </div>
    <div id="root"></div>
</body>
<script>
    let obj={
        name:'div',//指定渲染的标签
        props:{
            class:'box',
            id:'boxid',
            key:'1',
            children:['我是一个盒子','我是一个盒子']
        }
    }
    function render(obj,root) {
        let dom =document.createElement(obj.name)
        if(Object.keys(obj.props)){
            for (let key in obj.props) {
                if(key==='children'){
                    obj.props[key].forEach((item) => {
                        dom.innerHTML+=item
                    })
                }else{
                    dom.setAttribute(key,obj.props[key])
                }
            }
        }
        root.appendChild(dom)
    }
    render(obj,root);
</script>
</html>